{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1 задача\n",
    "\n",
    "1. Скачать данные по ссылке https://www.kaggle.com/datasets/ionaskel/laptop-prices\n",
    "2. Считать данные с помощью pandas\n",
    "3. Вывести на экран первые 5 строк"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Company</th>\n",
       "      <th>Product</th>\n",
       "      <th>TypeName</th>\n",
       "      <th>Inches</th>\n",
       "      <th>ScreenResolution</th>\n",
       "      <th>Cpu</th>\n",
       "      <th>Ram</th>\n",
       "      <th>Memory</th>\n",
       "      <th>Gpu</th>\n",
       "      <th>OpSys</th>\n",
       "      <th>Weight</th>\n",
       "      <th>Price_euros</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Apple</td>\n",
       "      <td>MacBook Pro</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>13.3</td>\n",
       "      <td>IPS Panel Retina Display 2560x1600</td>\n",
       "      <td>Intel Core i5 2.3GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>128GB SSD</td>\n",
       "      <td>Intel Iris Plus Graphics 640</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.37kg</td>\n",
       "      <td>1339.69</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Apple</td>\n",
       "      <td>Macbook Air</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>13.3</td>\n",
       "      <td>1440x900</td>\n",
       "      <td>Intel Core i5 1.8GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>128GB Flash Storage</td>\n",
       "      <td>Intel HD Graphics 6000</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.34kg</td>\n",
       "      <td>898.94</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>HP</td>\n",
       "      <td>250 G6</td>\n",
       "      <td>Notebook</td>\n",
       "      <td>15.6</td>\n",
       "      <td>Full HD 1920x1080</td>\n",
       "      <td>Intel Core i5 7200U 2.5GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>256GB SSD</td>\n",
       "      <td>Intel HD Graphics 620</td>\n",
       "      <td>No OS</td>\n",
       "      <td>1.86kg</td>\n",
       "      <td>575.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Apple</td>\n",
       "      <td>MacBook Pro</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>15.4</td>\n",
       "      <td>IPS Panel Retina Display 2880x1800</td>\n",
       "      <td>Intel Core i7 2.7GHz</td>\n",
       "      <td>16GB</td>\n",
       "      <td>512GB SSD</td>\n",
       "      <td>AMD Radeon Pro 455</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.83kg</td>\n",
       "      <td>2537.45</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Apple</td>\n",
       "      <td>MacBook Pro</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>13.3</td>\n",
       "      <td>IPS Panel Retina Display 2560x1600</td>\n",
       "      <td>Intel Core i5 3.1GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>256GB SSD</td>\n",
       "      <td>Intel Iris Plus Graphics 650</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.37kg</td>\n",
       "      <td>1803.60</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Company      Product   TypeName  Inches                    ScreenResolution  \\\n",
       "0   Apple  MacBook Pro  Ultrabook    13.3  IPS Panel Retina Display 2560x1600   \n",
       "1   Apple  Macbook Air  Ultrabook    13.3                            1440x900   \n",
       "2      HP       250 G6   Notebook    15.6                   Full HD 1920x1080   \n",
       "3   Apple  MacBook Pro  Ultrabook    15.4  IPS Panel Retina Display 2880x1800   \n",
       "4   Apple  MacBook Pro  Ultrabook    13.3  IPS Panel Retina Display 2560x1600   \n",
       "\n",
       "                          Cpu   Ram               Memory  \\\n",
       "0        Intel Core i5 2.3GHz   8GB            128GB SSD   \n",
       "1        Intel Core i5 1.8GHz   8GB  128GB Flash Storage   \n",
       "2  Intel Core i5 7200U 2.5GHz   8GB            256GB SSD   \n",
       "3        Intel Core i7 2.7GHz  16GB            512GB SSD   \n",
       "4        Intel Core i5 3.1GHz   8GB            256GB SSD   \n",
       "\n",
       "                            Gpu  OpSys  Weight  Price_euros  \n",
       "0  Intel Iris Plus Graphics 640  macOS  1.37kg      1339.69  \n",
       "1        Intel HD Graphics 6000  macOS  1.34kg       898.94  \n",
       "2         Intel HD Graphics 620  No OS  1.86kg       575.00  \n",
       "3            AMD Radeon Pro 455  macOS  1.83kg      2537.45  \n",
       "4  Intel Iris Plus Graphics 650  macOS  1.37kg      1803.60  "
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "\n",
    "# df = pd.read_csv('laptops.csv', sep=';')\n",
    "df = pd.read_csv(\"https://gbcdn.mrgcdn.ru/uploads/asset/5964765/attachment/53afdad3b710f8391be329e31b33f416.csv\", sep=\";\")\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.1 Создать новый признак Cpu_Company, который будет содержать только название фирмы, которая произвела CPU"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Company</th>\n",
       "      <th>Product</th>\n",
       "      <th>TypeName</th>\n",
       "      <th>Inches</th>\n",
       "      <th>ScreenResolution</th>\n",
       "      <th>Cpu</th>\n",
       "      <th>Ram</th>\n",
       "      <th>Memory</th>\n",
       "      <th>Gpu</th>\n",
       "      <th>OpSys</th>\n",
       "      <th>Weight</th>\n",
       "      <th>Price_euros</th>\n",
       "      <th>Cpu_Company</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Apple</td>\n",
       "      <td>MacBook Pro</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>13.3</td>\n",
       "      <td>IPS Panel Retina Display 2560x1600</td>\n",
       "      <td>Intel Core i5 2.3GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>128GB SSD</td>\n",
       "      <td>Intel Iris Plus Graphics 640</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.37kg</td>\n",
       "      <td>1339.69</td>\n",
       "      <td>Intel</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Apple</td>\n",
       "      <td>Macbook Air</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>13.3</td>\n",
       "      <td>1440x900</td>\n",
       "      <td>Intel Core i5 1.8GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>128GB Flash Storage</td>\n",
       "      <td>Intel HD Graphics 6000</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.34kg</td>\n",
       "      <td>898.94</td>\n",
       "      <td>Intel</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>HP</td>\n",
       "      <td>250 G6</td>\n",
       "      <td>Notebook</td>\n",
       "      <td>15.6</td>\n",
       "      <td>Full HD 1920x1080</td>\n",
       "      <td>Intel Core i5 7200U 2.5GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>256GB SSD</td>\n",
       "      <td>Intel HD Graphics 620</td>\n",
       "      <td>No OS</td>\n",
       "      <td>1.86kg</td>\n",
       "      <td>575.00</td>\n",
       "      <td>Intel</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Apple</td>\n",
       "      <td>MacBook Pro</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>15.4</td>\n",
       "      <td>IPS Panel Retina Display 2880x1800</td>\n",
       "      <td>Intel Core i7 2.7GHz</td>\n",
       "      <td>16GB</td>\n",
       "      <td>512GB SSD</td>\n",
       "      <td>AMD Radeon Pro 455</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.83kg</td>\n",
       "      <td>2537.45</td>\n",
       "      <td>Intel</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Apple</td>\n",
       "      <td>MacBook Pro</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>13.3</td>\n",
       "      <td>IPS Panel Retina Display 2560x1600</td>\n",
       "      <td>Intel Core i5 3.1GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>256GB SSD</td>\n",
       "      <td>Intel Iris Plus Graphics 650</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.37kg</td>\n",
       "      <td>1803.60</td>\n",
       "      <td>Intel</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Company      Product   TypeName  Inches                    ScreenResolution  \\\n",
       "0   Apple  MacBook Pro  Ultrabook    13.3  IPS Panel Retina Display 2560x1600   \n",
       "1   Apple  Macbook Air  Ultrabook    13.3                            1440x900   \n",
       "2      HP       250 G6   Notebook    15.6                   Full HD 1920x1080   \n",
       "3   Apple  MacBook Pro  Ultrabook    15.4  IPS Panel Retina Display 2880x1800   \n",
       "4   Apple  MacBook Pro  Ultrabook    13.3  IPS Panel Retina Display 2560x1600   \n",
       "\n",
       "                          Cpu   Ram               Memory  \\\n",
       "0        Intel Core i5 2.3GHz   8GB            128GB SSD   \n",
       "1        Intel Core i5 1.8GHz   8GB  128GB Flash Storage   \n",
       "2  Intel Core i5 7200U 2.5GHz   8GB            256GB SSD   \n",
       "3        Intel Core i7 2.7GHz  16GB            512GB SSD   \n",
       "4        Intel Core i5 3.1GHz   8GB            256GB SSD   \n",
       "\n",
       "                            Gpu  OpSys  Weight  Price_euros Cpu_Company  \n",
       "0  Intel Iris Plus Graphics 640  macOS  1.37kg      1339.69       Intel  \n",
       "1        Intel HD Graphics 6000  macOS  1.34kg       898.94       Intel  \n",
       "2         Intel HD Graphics 620  No OS  1.86kg       575.00       Intel  \n",
       "3            AMD Radeon Pro 455  macOS  1.83kg      2537.45       Intel  \n",
       "4  Intel Iris Plus Graphics 650  macOS  1.37kg      1803.60       Intel  "
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[\"Cpu_Company\"] = df[\"Cpu\"].apply(lambda x: x.split(\" \")[0])\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.2 Создать новый признак Memory_Amount, который будет содержать только количество Gb памяти без указания типа носителя"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Memory\n",
       "256GB SSD                        412\n",
       "1TB HDD                          223\n",
       "500GB HDD                        132\n",
       "512GB SSD                        118\n",
       "128GB SSD +  1TB HDD              94\n",
       "128GB SSD                         76\n",
       "256GB SSD +  1TB HDD              73\n",
       "32GB Flash Storage                38\n",
       "2TB HDD                           16\n",
       "64GB Flash Storage                15\n",
       "512GB SSD +  1TB HDD              14\n",
       "1TB SSD                           14\n",
       "256GB SSD +  2TB HDD              10\n",
       "1.0TB Hybrid                       9\n",
       "256GB Flash Storage                8\n",
       "16GB Flash Storage                 7\n",
       "32GB SSD                           6\n",
       "180GB SSD                          5\n",
       "128GB Flash Storage                4\n",
       "512GB SSD +  2TB HDD               3\n",
       "16GB SSD                           3\n",
       "512GB Flash Storage                2\n",
       "1TB SSD +  1TB HDD                 2\n",
       "256GB SSD +  500GB HDD             2\n",
       "128GB SSD +  2TB HDD               2\n",
       "256GB SSD +  256GB SSD             2\n",
       "512GB SSD +  256GB SSD             1\n",
       "512GB SSD +  512GB SSD             1\n",
       "64GB Flash Storage +  1TB HDD      1\n",
       "1TB HDD +  1TB HDD                 1\n",
       "32GB HDD                           1\n",
       "64GB SSD                           1\n",
       "128GB HDD                          1\n",
       "240GB SSD                          1\n",
       "8GB SSD                            1\n",
       "508GB Hybrid                       1\n",
       "1.0TB HDD                          1\n",
       "512GB SSD +  1.0TB Hybrid          1\n",
       "256GB SSD +  1.0TB Hybrid          1\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[\"Memory\"].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Company</th>\n",
       "      <th>Product</th>\n",
       "      <th>TypeName</th>\n",
       "      <th>Inches</th>\n",
       "      <th>ScreenResolution</th>\n",
       "      <th>Cpu</th>\n",
       "      <th>Ram</th>\n",
       "      <th>Memory</th>\n",
       "      <th>Gpu</th>\n",
       "      <th>OpSys</th>\n",
       "      <th>Weight</th>\n",
       "      <th>Price_euros</th>\n",
       "      <th>Cpu_Company</th>\n",
       "      <th>Memory_Amount</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Apple</td>\n",
       "      <td>MacBook Pro</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>13.3</td>\n",
       "      <td>IPS Panel Retina Display 2560x1600</td>\n",
       "      <td>Intel Core i5 2.3GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>128GB SSD</td>\n",
       "      <td>Intel Iris Plus Graphics 640</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.37kg</td>\n",
       "      <td>1339.69</td>\n",
       "      <td>Intel</td>\n",
       "      <td>128</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Apple</td>\n",
       "      <td>Macbook Air</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>13.3</td>\n",
       "      <td>1440x900</td>\n",
       "      <td>Intel Core i5 1.8GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>128GB Flash Storage</td>\n",
       "      <td>Intel HD Graphics 6000</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.34kg</td>\n",
       "      <td>898.94</td>\n",
       "      <td>Intel</td>\n",
       "      <td>128</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>HP</td>\n",
       "      <td>250 G6</td>\n",
       "      <td>Notebook</td>\n",
       "      <td>15.6</td>\n",
       "      <td>Full HD 1920x1080</td>\n",
       "      <td>Intel Core i5 7200U 2.5GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>256GB SSD</td>\n",
       "      <td>Intel HD Graphics 620</td>\n",
       "      <td>No OS</td>\n",
       "      <td>1.86kg</td>\n",
       "      <td>575.00</td>\n",
       "      <td>Intel</td>\n",
       "      <td>256</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Apple</td>\n",
       "      <td>MacBook Pro</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>15.4</td>\n",
       "      <td>IPS Panel Retina Display 2880x1800</td>\n",
       "      <td>Intel Core i7 2.7GHz</td>\n",
       "      <td>16GB</td>\n",
       "      <td>512GB SSD</td>\n",
       "      <td>AMD Radeon Pro 455</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.83kg</td>\n",
       "      <td>2537.45</td>\n",
       "      <td>Intel</td>\n",
       "      <td>512</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Apple</td>\n",
       "      <td>MacBook Pro</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>13.3</td>\n",
       "      <td>IPS Panel Retina Display 2560x1600</td>\n",
       "      <td>Intel Core i5 3.1GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>256GB SSD</td>\n",
       "      <td>Intel Iris Plus Graphics 650</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.37kg</td>\n",
       "      <td>1803.60</td>\n",
       "      <td>Intel</td>\n",
       "      <td>256</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Company      Product   TypeName  Inches                    ScreenResolution  \\\n",
       "0   Apple  MacBook Pro  Ultrabook    13.3  IPS Panel Retina Display 2560x1600   \n",
       "1   Apple  Macbook Air  Ultrabook    13.3                            1440x900   \n",
       "2      HP       250 G6   Notebook    15.6                   Full HD 1920x1080   \n",
       "3   Apple  MacBook Pro  Ultrabook    15.4  IPS Panel Retina Display 2880x1800   \n",
       "4   Apple  MacBook Pro  Ultrabook    13.3  IPS Panel Retina Display 2560x1600   \n",
       "\n",
       "                          Cpu   Ram               Memory  \\\n",
       "0        Intel Core i5 2.3GHz   8GB            128GB SSD   \n",
       "1        Intel Core i5 1.8GHz   8GB  128GB Flash Storage   \n",
       "2  Intel Core i5 7200U 2.5GHz   8GB            256GB SSD   \n",
       "3        Intel Core i7 2.7GHz  16GB            512GB SSD   \n",
       "4        Intel Core i5 3.1GHz   8GB            256GB SSD   \n",
       "\n",
       "                            Gpu  OpSys  Weight  Price_euros Cpu_Company  \\\n",
       "0  Intel Iris Plus Graphics 640  macOS  1.37kg      1339.69       Intel   \n",
       "1        Intel HD Graphics 6000  macOS  1.34kg       898.94       Intel   \n",
       "2         Intel HD Graphics 620  No OS  1.86kg       575.00       Intel   \n",
       "3            AMD Radeon Pro 455  macOS  1.83kg      2537.45       Intel   \n",
       "4  Intel Iris Plus Graphics 650  macOS  1.37kg      1803.60       Intel   \n",
       "\n",
       "   Memory_Amount  \n",
       "0            128  \n",
       "1            128  \n",
       "2            256  \n",
       "3            512  \n",
       "4            256  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def convert_to_gb(x):\n",
    "    memory = x.split(\" \")[0]\n",
    "    if memory.endswith(\"GB\"):\n",
    "        res = memory.replace(\"GB\", \"\")\n",
    "    elif memory.endswith(\"TB\"):\n",
    "        res = float(memory.replace(\"TB\", \"\")) * 1024\n",
    "    return int(res)\n",
    "\n",
    "\n",
    "df[\"Memory_Amount\"] = df[\"Memory\"].apply(convert_to_gb)\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.3 Создать новый признак Memory_Type, который будет содержать только тип носителя (HDD/SDD/др.)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Company</th>\n",
       "      <th>Product</th>\n",
       "      <th>TypeName</th>\n",
       "      <th>Inches</th>\n",
       "      <th>ScreenResolution</th>\n",
       "      <th>Cpu</th>\n",
       "      <th>Ram</th>\n",
       "      <th>Memory</th>\n",
       "      <th>Gpu</th>\n",
       "      <th>OpSys</th>\n",
       "      <th>Weight</th>\n",
       "      <th>Price_euros</th>\n",
       "      <th>Cpu_Company</th>\n",
       "      <th>Memory_Amount</th>\n",
       "      <th>Memory_Type</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Apple</td>\n",
       "      <td>MacBook Pro</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>13.3</td>\n",
       "      <td>IPS Panel Retina Display 2560x1600</td>\n",
       "      <td>Intel Core i5 2.3GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>128GB SSD</td>\n",
       "      <td>Intel Iris Plus Graphics 640</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.37kg</td>\n",
       "      <td>1339.69</td>\n",
       "      <td>Intel</td>\n",
       "      <td>128</td>\n",
       "      <td>SSD</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Apple</td>\n",
       "      <td>Macbook Air</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>13.3</td>\n",
       "      <td>1440x900</td>\n",
       "      <td>Intel Core i5 1.8GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>128GB Flash Storage</td>\n",
       "      <td>Intel HD Graphics 6000</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.34kg</td>\n",
       "      <td>898.94</td>\n",
       "      <td>Intel</td>\n",
       "      <td>128</td>\n",
       "      <td>FlashStorage</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>HP</td>\n",
       "      <td>250 G6</td>\n",
       "      <td>Notebook</td>\n",
       "      <td>15.6</td>\n",
       "      <td>Full HD 1920x1080</td>\n",
       "      <td>Intel Core i5 7200U 2.5GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>256GB SSD</td>\n",
       "      <td>Intel HD Graphics 620</td>\n",
       "      <td>No OS</td>\n",
       "      <td>1.86kg</td>\n",
       "      <td>575.00</td>\n",
       "      <td>Intel</td>\n",
       "      <td>256</td>\n",
       "      <td>SSD</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Apple</td>\n",
       "      <td>MacBook Pro</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>15.4</td>\n",
       "      <td>IPS Panel Retina Display 2880x1800</td>\n",
       "      <td>Intel Core i7 2.7GHz</td>\n",
       "      <td>16GB</td>\n",
       "      <td>512GB SSD</td>\n",
       "      <td>AMD Radeon Pro 455</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.83kg</td>\n",
       "      <td>2537.45</td>\n",
       "      <td>Intel</td>\n",
       "      <td>512</td>\n",
       "      <td>SSD</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Apple</td>\n",
       "      <td>MacBook Pro</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>13.3</td>\n",
       "      <td>IPS Panel Retina Display 2560x1600</td>\n",
       "      <td>Intel Core i5 3.1GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>256GB SSD</td>\n",
       "      <td>Intel Iris Plus Graphics 650</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.37kg</td>\n",
       "      <td>1803.60</td>\n",
       "      <td>Intel</td>\n",
       "      <td>256</td>\n",
       "      <td>SSD</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Company      Product   TypeName  Inches                    ScreenResolution  \\\n",
       "0   Apple  MacBook Pro  Ultrabook    13.3  IPS Panel Retina Display 2560x1600   \n",
       "1   Apple  Macbook Air  Ultrabook    13.3                            1440x900   \n",
       "2      HP       250 G6   Notebook    15.6                   Full HD 1920x1080   \n",
       "3   Apple  MacBook Pro  Ultrabook    15.4  IPS Panel Retina Display 2880x1800   \n",
       "4   Apple  MacBook Pro  Ultrabook    13.3  IPS Panel Retina Display 2560x1600   \n",
       "\n",
       "                          Cpu   Ram               Memory  \\\n",
       "0        Intel Core i5 2.3GHz   8GB            128GB SSD   \n",
       "1        Intel Core i5 1.8GHz   8GB  128GB Flash Storage   \n",
       "2  Intel Core i5 7200U 2.5GHz   8GB            256GB SSD   \n",
       "3        Intel Core i7 2.7GHz  16GB            512GB SSD   \n",
       "4        Intel Core i5 3.1GHz   8GB            256GB SSD   \n",
       "\n",
       "                            Gpu  OpSys  Weight  Price_euros Cpu_Company  \\\n",
       "0  Intel Iris Plus Graphics 640  macOS  1.37kg      1339.69       Intel   \n",
       "1        Intel HD Graphics 6000  macOS  1.34kg       898.94       Intel   \n",
       "2         Intel HD Graphics 620  No OS  1.86kg       575.00       Intel   \n",
       "3            AMD Radeon Pro 455  macOS  1.83kg      2537.45       Intel   \n",
       "4  Intel Iris Plus Graphics 650  macOS  1.37kg      1803.60       Intel   \n",
       "\n",
       "   Memory_Amount   Memory_Type  \n",
       "0            128           SSD  \n",
       "1            128  FlashStorage  \n",
       "2            256           SSD  \n",
       "3            512           SSD  \n",
       "4            256           SSD  "
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def convert_to_type(x):\n",
    "    type_memory = x.replace(\" \", \"\").split(\"B\")[-1]\n",
    "    return type_memory\n",
    "\n",
    "\n",
    "df[\"Memory_Type\"] = df[\"Memory\"].apply(convert_to_type)\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.4 Удалите признаки Memory и ScreenResolution"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Company</th>\n",
       "      <th>Product</th>\n",
       "      <th>TypeName</th>\n",
       "      <th>Inches</th>\n",
       "      <th>Cpu</th>\n",
       "      <th>Ram</th>\n",
       "      <th>Gpu</th>\n",
       "      <th>OpSys</th>\n",
       "      <th>Weight</th>\n",
       "      <th>Price_euros</th>\n",
       "      <th>Cpu_Company</th>\n",
       "      <th>Memory_Amount</th>\n",
       "      <th>Memory_Type</th>\n",
       "      <th>SSD</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Apple</td>\n",
       "      <td>MacBook Pro</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>13.3</td>\n",
       "      <td>Intel Core i5 2.3GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>Intel Iris Plus Graphics 640</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.37kg</td>\n",
       "      <td>1339.69</td>\n",
       "      <td>Intel</td>\n",
       "      <td>128</td>\n",
       "      <td>SSD</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Apple</td>\n",
       "      <td>Macbook Air</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>13.3</td>\n",
       "      <td>Intel Core i5 1.8GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>Intel HD Graphics 6000</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.34kg</td>\n",
       "      <td>898.94</td>\n",
       "      <td>Intel</td>\n",
       "      <td>128</td>\n",
       "      <td>FlashStorage</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>HP</td>\n",
       "      <td>250 G6</td>\n",
       "      <td>Notebook</td>\n",
       "      <td>15.6</td>\n",
       "      <td>Intel Core i5 7200U 2.5GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>Intel HD Graphics 620</td>\n",
       "      <td>No OS</td>\n",
       "      <td>1.86kg</td>\n",
       "      <td>575.00</td>\n",
       "      <td>Intel</td>\n",
       "      <td>256</td>\n",
       "      <td>SSD</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Apple</td>\n",
       "      <td>MacBook Pro</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>15.4</td>\n",
       "      <td>Intel Core i7 2.7GHz</td>\n",
       "      <td>16GB</td>\n",
       "      <td>AMD Radeon Pro 455</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.83kg</td>\n",
       "      <td>2537.45</td>\n",
       "      <td>Intel</td>\n",
       "      <td>512</td>\n",
       "      <td>SSD</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Apple</td>\n",
       "      <td>MacBook Pro</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>13.3</td>\n",
       "      <td>Intel Core i5 3.1GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>Intel Iris Plus Graphics 650</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.37kg</td>\n",
       "      <td>1803.60</td>\n",
       "      <td>Intel</td>\n",
       "      <td>256</td>\n",
       "      <td>SSD</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Company      Product   TypeName  Inches                         Cpu   Ram  \\\n",
       "0   Apple  MacBook Pro  Ultrabook    13.3        Intel Core i5 2.3GHz   8GB   \n",
       "1   Apple  Macbook Air  Ultrabook    13.3        Intel Core i5 1.8GHz   8GB   \n",
       "2      HP       250 G6   Notebook    15.6  Intel Core i5 7200U 2.5GHz   8GB   \n",
       "3   Apple  MacBook Pro  Ultrabook    15.4        Intel Core i7 2.7GHz  16GB   \n",
       "4   Apple  MacBook Pro  Ultrabook    13.3        Intel Core i5 3.1GHz   8GB   \n",
       "\n",
       "                            Gpu  OpSys  Weight  Price_euros Cpu_Company  \\\n",
       "0  Intel Iris Plus Graphics 640  macOS  1.37kg      1339.69       Intel   \n",
       "1        Intel HD Graphics 6000  macOS  1.34kg       898.94       Intel   \n",
       "2         Intel HD Graphics 620  No OS  1.86kg       575.00       Intel   \n",
       "3            AMD Radeon Pro 455  macOS  1.83kg      2537.45       Intel   \n",
       "4  Intel Iris Plus Graphics 650  macOS  1.37kg      1803.60       Intel   \n",
       "\n",
       "   Memory_Amount   Memory_Type  SSD  \n",
       "0            128           SSD    0  \n",
       "1            128  FlashStorage    0  \n",
       "2            256           SSD    0  \n",
       "3            512           SSD    0  \n",
       "4            256           SSD    0  "
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.drop(columns=[\"Memory\", \"ScreenResolution\"], inplace=True)\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2 задача"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2.1 Создайте признак SSD, который изначально равен 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Company</th>\n",
       "      <th>Product</th>\n",
       "      <th>TypeName</th>\n",
       "      <th>Inches</th>\n",
       "      <th>Cpu</th>\n",
       "      <th>Ram</th>\n",
       "      <th>Gpu</th>\n",
       "      <th>OpSys</th>\n",
       "      <th>Weight</th>\n",
       "      <th>Price_euros</th>\n",
       "      <th>Cpu_Company</th>\n",
       "      <th>Memory_Amount</th>\n",
       "      <th>Memory_Type</th>\n",
       "      <th>SSD</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Apple</td>\n",
       "      <td>MacBook Pro</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>13.3</td>\n",
       "      <td>Intel Core i5 2.3GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>Intel Iris Plus Graphics 640</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.37kg</td>\n",
       "      <td>1339.69</td>\n",
       "      <td>Intel</td>\n",
       "      <td>128</td>\n",
       "      <td>SSD</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Apple</td>\n",
       "      <td>Macbook Air</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>13.3</td>\n",
       "      <td>Intel Core i5 1.8GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>Intel HD Graphics 6000</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.34kg</td>\n",
       "      <td>898.94</td>\n",
       "      <td>Intel</td>\n",
       "      <td>128</td>\n",
       "      <td>FlashStorage</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>HP</td>\n",
       "      <td>250 G6</td>\n",
       "      <td>Notebook</td>\n",
       "      <td>15.6</td>\n",
       "      <td>Intel Core i5 7200U 2.5GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>Intel HD Graphics 620</td>\n",
       "      <td>No OS</td>\n",
       "      <td>1.86kg</td>\n",
       "      <td>575.00</td>\n",
       "      <td>Intel</td>\n",
       "      <td>256</td>\n",
       "      <td>SSD</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Apple</td>\n",
       "      <td>MacBook Pro</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>15.4</td>\n",
       "      <td>Intel Core i7 2.7GHz</td>\n",
       "      <td>16GB</td>\n",
       "      <td>AMD Radeon Pro 455</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.83kg</td>\n",
       "      <td>2537.45</td>\n",
       "      <td>Intel</td>\n",
       "      <td>512</td>\n",
       "      <td>SSD</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Apple</td>\n",
       "      <td>MacBook Pro</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>13.3</td>\n",
       "      <td>Intel Core i5 3.1GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>Intel Iris Plus Graphics 650</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.37kg</td>\n",
       "      <td>1803.60</td>\n",
       "      <td>Intel</td>\n",
       "      <td>256</td>\n",
       "      <td>SSD</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Company      Product   TypeName  Inches                         Cpu   Ram  \\\n",
       "0   Apple  MacBook Pro  Ultrabook    13.3        Intel Core i5 2.3GHz   8GB   \n",
       "1   Apple  Macbook Air  Ultrabook    13.3        Intel Core i5 1.8GHz   8GB   \n",
       "2      HP       250 G6   Notebook    15.6  Intel Core i5 7200U 2.5GHz   8GB   \n",
       "3   Apple  MacBook Pro  Ultrabook    15.4        Intel Core i7 2.7GHz  16GB   \n",
       "4   Apple  MacBook Pro  Ultrabook    13.3        Intel Core i5 3.1GHz   8GB   \n",
       "\n",
       "                            Gpu  OpSys  Weight  Price_euros Cpu_Company  \\\n",
       "0  Intel Iris Plus Graphics 640  macOS  1.37kg      1339.69       Intel   \n",
       "1        Intel HD Graphics 6000  macOS  1.34kg       898.94       Intel   \n",
       "2         Intel HD Graphics 620  No OS  1.86kg       575.00       Intel   \n",
       "3            AMD Radeon Pro 455  macOS  1.83kg      2537.45       Intel   \n",
       "4  Intel Iris Plus Graphics 650  macOS  1.37kg      1803.60       Intel   \n",
       "\n",
       "   Memory_Amount   Memory_Type  SSD  \n",
       "0            128           SSD    0  \n",
       "1            128  FlashStorage    0  \n",
       "2            256           SSD    0  \n",
       "3            512           SSD    0  \n",
       "4            256           SSD    0  "
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[\"SSD\"] = 0\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2.2 Поставьте в признаке SSD 1, если ноутбук действительно с типом носителя SSD"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Company</th>\n",
       "      <th>Product</th>\n",
       "      <th>TypeName</th>\n",
       "      <th>Inches</th>\n",
       "      <th>Cpu</th>\n",
       "      <th>Ram</th>\n",
       "      <th>Gpu</th>\n",
       "      <th>OpSys</th>\n",
       "      <th>Weight</th>\n",
       "      <th>Price_euros</th>\n",
       "      <th>Cpu_Company</th>\n",
       "      <th>Memory_Amount</th>\n",
       "      <th>Memory_Type</th>\n",
       "      <th>SSD</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Apple</td>\n",
       "      <td>MacBook Pro</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>13.3</td>\n",
       "      <td>Intel Core i5 2.3GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>Intel Iris Plus Graphics 640</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.37kg</td>\n",
       "      <td>1339.69</td>\n",
       "      <td>Intel</td>\n",
       "      <td>128</td>\n",
       "      <td>SSD</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Apple</td>\n",
       "      <td>Macbook Air</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>13.3</td>\n",
       "      <td>Intel Core i5 1.8GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>Intel HD Graphics 6000</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.34kg</td>\n",
       "      <td>898.94</td>\n",
       "      <td>Intel</td>\n",
       "      <td>128</td>\n",
       "      <td>FlashStorage</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>HP</td>\n",
       "      <td>250 G6</td>\n",
       "      <td>Notebook</td>\n",
       "      <td>15.6</td>\n",
       "      <td>Intel Core i5 7200U 2.5GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>Intel HD Graphics 620</td>\n",
       "      <td>No OS</td>\n",
       "      <td>1.86kg</td>\n",
       "      <td>575.00</td>\n",
       "      <td>Intel</td>\n",
       "      <td>256</td>\n",
       "      <td>SSD</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Apple</td>\n",
       "      <td>MacBook Pro</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>15.4</td>\n",
       "      <td>Intel Core i7 2.7GHz</td>\n",
       "      <td>16GB</td>\n",
       "      <td>AMD Radeon Pro 455</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.83kg</td>\n",
       "      <td>2537.45</td>\n",
       "      <td>Intel</td>\n",
       "      <td>512</td>\n",
       "      <td>SSD</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Apple</td>\n",
       "      <td>MacBook Pro</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>13.3</td>\n",
       "      <td>Intel Core i5 3.1GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>Intel Iris Plus Graphics 650</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.37kg</td>\n",
       "      <td>1803.60</td>\n",
       "      <td>Intel</td>\n",
       "      <td>256</td>\n",
       "      <td>SSD</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Company      Product   TypeName  Inches                         Cpu   Ram  \\\n",
       "0   Apple  MacBook Pro  Ultrabook    13.3        Intel Core i5 2.3GHz   8GB   \n",
       "1   Apple  Macbook Air  Ultrabook    13.3        Intel Core i5 1.8GHz   8GB   \n",
       "2      HP       250 G6   Notebook    15.6  Intel Core i5 7200U 2.5GHz   8GB   \n",
       "3   Apple  MacBook Pro  Ultrabook    15.4        Intel Core i7 2.7GHz  16GB   \n",
       "4   Apple  MacBook Pro  Ultrabook    13.3        Intel Core i5 3.1GHz   8GB   \n",
       "\n",
       "                            Gpu  OpSys  Weight  Price_euros Cpu_Company  \\\n",
       "0  Intel Iris Plus Graphics 640  macOS  1.37kg      1339.69       Intel   \n",
       "1        Intel HD Graphics 6000  macOS  1.34kg       898.94       Intel   \n",
       "2         Intel HD Graphics 620  No OS  1.86kg       575.00       Intel   \n",
       "3            AMD Radeon Pro 455  macOS  1.83kg      2537.45       Intel   \n",
       "4  Intel Iris Plus Graphics 650  macOS  1.37kg      1803.60       Intel   \n",
       "\n",
       "   Memory_Amount   Memory_Type  SSD  \n",
       "0            128           SSD    1  \n",
       "1            128  FlashStorage    0  \n",
       "2            256           SSD    1  \n",
       "3            512           SSD    1  \n",
       "4            256           SSD    1  "
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[df[\"Memory_Type\"] == \"SSD\", \"SSD\"] = 1\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2.3 Уберите в признаке Weight значения 'kg' и поменяйте его тип данных на вещественный"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Company</th>\n",
       "      <th>Product</th>\n",
       "      <th>TypeName</th>\n",
       "      <th>Inches</th>\n",
       "      <th>Cpu</th>\n",
       "      <th>Ram</th>\n",
       "      <th>Gpu</th>\n",
       "      <th>OpSys</th>\n",
       "      <th>Weight</th>\n",
       "      <th>Price_euros</th>\n",
       "      <th>Cpu_Company</th>\n",
       "      <th>Memory_Amount</th>\n",
       "      <th>Memory_Type</th>\n",
       "      <th>SSD</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Apple</td>\n",
       "      <td>MacBook Pro</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>13.3</td>\n",
       "      <td>Intel Core i5 2.3GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>Intel Iris Plus Graphics 640</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.37</td>\n",
       "      <td>1339.69</td>\n",
       "      <td>Intel</td>\n",
       "      <td>128</td>\n",
       "      <td>SSD</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Apple</td>\n",
       "      <td>Macbook Air</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>13.3</td>\n",
       "      <td>Intel Core i5 1.8GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>Intel HD Graphics 6000</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.34</td>\n",
       "      <td>898.94</td>\n",
       "      <td>Intel</td>\n",
       "      <td>128</td>\n",
       "      <td>FlashStorage</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>HP</td>\n",
       "      <td>250 G6</td>\n",
       "      <td>Notebook</td>\n",
       "      <td>15.6</td>\n",
       "      <td>Intel Core i5 7200U 2.5GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>Intel HD Graphics 620</td>\n",
       "      <td>No OS</td>\n",
       "      <td>1.86</td>\n",
       "      <td>575.00</td>\n",
       "      <td>Intel</td>\n",
       "      <td>256</td>\n",
       "      <td>SSD</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Apple</td>\n",
       "      <td>MacBook Pro</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>15.4</td>\n",
       "      <td>Intel Core i7 2.7GHz</td>\n",
       "      <td>16GB</td>\n",
       "      <td>AMD Radeon Pro 455</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.83</td>\n",
       "      <td>2537.45</td>\n",
       "      <td>Intel</td>\n",
       "      <td>512</td>\n",
       "      <td>SSD</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Apple</td>\n",
       "      <td>MacBook Pro</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>13.3</td>\n",
       "      <td>Intel Core i5 3.1GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>Intel Iris Plus Graphics 650</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.37</td>\n",
       "      <td>1803.60</td>\n",
       "      <td>Intel</td>\n",
       "      <td>256</td>\n",
       "      <td>SSD</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Company      Product   TypeName  Inches                         Cpu   Ram  \\\n",
       "0   Apple  MacBook Pro  Ultrabook    13.3        Intel Core i5 2.3GHz   8GB   \n",
       "1   Apple  Macbook Air  Ultrabook    13.3        Intel Core i5 1.8GHz   8GB   \n",
       "2      HP       250 G6   Notebook    15.6  Intel Core i5 7200U 2.5GHz   8GB   \n",
       "3   Apple  MacBook Pro  Ultrabook    15.4        Intel Core i7 2.7GHz  16GB   \n",
       "4   Apple  MacBook Pro  Ultrabook    13.3        Intel Core i5 3.1GHz   8GB   \n",
       "\n",
       "                            Gpu  OpSys  Weight  Price_euros Cpu_Company  \\\n",
       "0  Intel Iris Plus Graphics 640  macOS    1.37      1339.69       Intel   \n",
       "1        Intel HD Graphics 6000  macOS    1.34       898.94       Intel   \n",
       "2         Intel HD Graphics 620  No OS    1.86       575.00       Intel   \n",
       "3            AMD Radeon Pro 455  macOS    1.83      2537.45       Intel   \n",
       "4  Intel Iris Plus Graphics 650  macOS    1.37      1803.60       Intel   \n",
       "\n",
       "   Memory_Amount   Memory_Type  SSD  \n",
       "0            128           SSD    1  \n",
       "1            128  FlashStorage    0  \n",
       "2            256           SSD    1  \n",
       "3            512           SSD    1  \n",
       "4            256           SSD    1  "
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[\"Weight\"] = df[\"Weight\"].str.replace(\"kg\", \"\")\n",
    "df[\"Weight\"] = df[\"Weight\"].astype(\"float\")\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dtype('float64')"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[\"Weight\"].dtype"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3 задача\n",
    "\n",
    "Создайте датафрейм с клиентами:\n",
    "\n",
    "```\n",
    "clients = pd.DataFrame({\n",
    "    'client_id': [45, 32, 67, 33, 43],\n",
    "    'laptop_id': [506, 398, 710, 120, 1999]\n",
    "})\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>client_id</th>\n",
       "      <th>laptop_id</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>45</td>\n",
       "      <td>506</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>32</td>\n",
       "      <td>398</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>67</td>\n",
       "      <td>710</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>33</td>\n",
       "      <td>120</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>43</td>\n",
       "      <td>1999</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   client_id  laptop_id\n",
       "0         45        506\n",
       "1         32        398\n",
       "2         67        710\n",
       "3         33        120\n",
       "4         43       1999"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "clients = pd.DataFrame(\n",
    "    {\"client_id\": [45, 32, 67, 33, 43], \"laptop_id\": [506, 398, 710, 120, 1999]}\n",
    ")\n",
    "clients"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3.1 Присоедините к таблице clients данные по ноутбукам через метод join\n",
    "\n",
    "Это нужно, чтобы понимать, какие ноутбуки покупались клиентами\n",
    "\n",
    "laptop_id  - это индексы датафрейма с ноутбуками"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>client_id</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>laptop_id</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>506</th>\n",
       "      <td>45</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>398</th>\n",
       "      <td>32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>710</th>\n",
       "      <td>67</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>120</th>\n",
       "      <td>33</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1999</th>\n",
       "      <td>43</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           client_id\n",
       "laptop_id           \n",
       "506               45\n",
       "398               32\n",
       "710               67\n",
       "120               33\n",
       "1999              43"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "clients_lap_id = clients.set_index(\"laptop_id\")\n",
    "clients_lap_id"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>client_id</th>\n",
       "      <th>Company</th>\n",
       "      <th>Product</th>\n",
       "      <th>TypeName</th>\n",
       "      <th>Inches</th>\n",
       "      <th>Cpu</th>\n",
       "      <th>Ram</th>\n",
       "      <th>Gpu</th>\n",
       "      <th>OpSys</th>\n",
       "      <th>Weight</th>\n",
       "      <th>Price_euros</th>\n",
       "      <th>Cpu_Company</th>\n",
       "      <th>Memory_Amount</th>\n",
       "      <th>Memory_Type</th>\n",
       "      <th>SSD</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>laptop_id</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>506</th>\n",
       "      <td>45</td>\n",
       "      <td>Asus</td>\n",
       "      <td>ZenBook UX510UX-CN211T</td>\n",
       "      <td>Notebook</td>\n",
       "      <td>15.6</td>\n",
       "      <td>Intel Core i7 7500U 2.7GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>Intel HD Graphics 620</td>\n",
       "      <td>Windows 10</td>\n",
       "      <td>2kg</td>\n",
       "      <td>1224.0</td>\n",
       "      <td>Intel</td>\n",
       "      <td>256.0</td>\n",
       "      <td>HDD</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>398</th>\n",
       "      <td>32</td>\n",
       "      <td>Dell</td>\n",
       "      <td>Precision M5520</td>\n",
       "      <td>Workstation</td>\n",
       "      <td>15.6</td>\n",
       "      <td>Intel Core i7 7700HQ 2.8GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>Nvidia Quadro M1200</td>\n",
       "      <td>Windows 10</td>\n",
       "      <td>1.78kg</td>\n",
       "      <td>2712.0</td>\n",
       "      <td>Intel</td>\n",
       "      <td>256.0</td>\n",
       "      <td>SSD</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>710</th>\n",
       "      <td>67</td>\n",
       "      <td>Lenovo</td>\n",
       "      <td>Legion Y520-15IKBN</td>\n",
       "      <td>Gaming</td>\n",
       "      <td>15.6</td>\n",
       "      <td>Intel Core i7 7700HQ 2.8GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>Nvidia GeForce GTX 1050 Ti</td>\n",
       "      <td>Windows 10</td>\n",
       "      <td>2.5kg</td>\n",
       "      <td>1249.0</td>\n",
       "      <td>Intel</td>\n",
       "      <td>128.0</td>\n",
       "      <td>HDD</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>120</th>\n",
       "      <td>33</td>\n",
       "      <td>Acer</td>\n",
       "      <td>Spin 3</td>\n",
       "      <td>Notebook</td>\n",
       "      <td>15.6</td>\n",
       "      <td>Intel Core i3 7100U 2.4GHz</td>\n",
       "      <td>6GB</td>\n",
       "      <td>Intel HD Graphics 620</td>\n",
       "      <td>Windows 10</td>\n",
       "      <td>2.1kg</td>\n",
       "      <td>479.0</td>\n",
       "      <td>Intel</td>\n",
       "      <td>1024.0</td>\n",
       "      <td>HDD</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1999</th>\n",
       "      <td>43</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           client_id Company                 Product     TypeName  Inches  \\\n",
       "laptop_id                                                                   \n",
       "506               45    Asus  ZenBook UX510UX-CN211T     Notebook    15.6   \n",
       "398               32    Dell         Precision M5520  Workstation    15.6   \n",
       "710               67  Lenovo      Legion Y520-15IKBN       Gaming    15.6   \n",
       "120               33    Acer                  Spin 3     Notebook    15.6   \n",
       "1999              43     NaN                     NaN          NaN     NaN   \n",
       "\n",
       "                                   Cpu  Ram                         Gpu  \\\n",
       "laptop_id                                                                 \n",
       "506         Intel Core i7 7500U 2.7GHz  8GB       Intel HD Graphics 620   \n",
       "398        Intel Core i7 7700HQ 2.8GHz  8GB         Nvidia Quadro M1200   \n",
       "710        Intel Core i7 7700HQ 2.8GHz  8GB  Nvidia GeForce GTX 1050 Ti   \n",
       "120         Intel Core i3 7100U 2.4GHz  6GB       Intel HD Graphics 620   \n",
       "1999                               NaN  NaN                         NaN   \n",
       "\n",
       "                OpSys  Weight  Price_euros Cpu_Company  Memory_Amount  \\\n",
       "laptop_id                                                               \n",
       "506        Windows 10     2kg       1224.0       Intel          256.0   \n",
       "398        Windows 10  1.78kg       2712.0       Intel          256.0   \n",
       "710        Windows 10   2.5kg       1249.0       Intel          128.0   \n",
       "120        Windows 10   2.1kg        479.0       Intel         1024.0   \n",
       "1999              NaN     NaN          NaN         NaN            NaN   \n",
       "\n",
       "          Memory_Type  SSD  \n",
       "laptop_id                   \n",
       "506               HDD  0.0  \n",
       "398               SSD  1.0  \n",
       "710               HDD  0.0  \n",
       "120               HDD  0.0  \n",
       "1999              NaN  NaN  "
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "joined = clients_lap_id.join(df)\n",
    "joined"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3.2 Присоедините к таблице clients данные по ноутбукам через метод merge\n",
    "\n",
    "Это нужно, чтобы понимать, какие ноутбуки покупались клиентами\n",
    "\n",
    "laptop_id  - это индексы датафрейма с ноутбуками"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>client_id</th>\n",
       "      <th>laptop_id</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>45</td>\n",
       "      <td>506</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>32</td>\n",
       "      <td>398</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>67</td>\n",
       "      <td>710</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>33</td>\n",
       "      <td>120</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>43</td>\n",
       "      <td>1999</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   client_id  laptop_id\n",
       "0         45        506\n",
       "1         32        398\n",
       "2         67        710\n",
       "3         33        120\n",
       "4         43       1999"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "clients"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Company</th>\n",
       "      <th>Product</th>\n",
       "      <th>TypeName</th>\n",
       "      <th>Inches</th>\n",
       "      <th>Cpu</th>\n",
       "      <th>Ram</th>\n",
       "      <th>Gpu</th>\n",
       "      <th>OpSys</th>\n",
       "      <th>Weight</th>\n",
       "      <th>Price_euros</th>\n",
       "      <th>Cpu_Company</th>\n",
       "      <th>Memory_Amount</th>\n",
       "      <th>Memory_Type</th>\n",
       "      <th>SSD</th>\n",
       "      <th>laptop_id</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Apple</td>\n",
       "      <td>MacBook Pro</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>13.3</td>\n",
       "      <td>Intel Core i5 2.3GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>Intel Iris Plus Graphics 640</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.37kg</td>\n",
       "      <td>1339.69</td>\n",
       "      <td>Intel</td>\n",
       "      <td>128</td>\n",
       "      <td>SSD</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Apple</td>\n",
       "      <td>Macbook Air</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>13.3</td>\n",
       "      <td>Intel Core i5 1.8GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>Intel HD Graphics 6000</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.34kg</td>\n",
       "      <td>898.94</td>\n",
       "      <td>Intel</td>\n",
       "      <td>128</td>\n",
       "      <td>FlashStorage</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>HP</td>\n",
       "      <td>250 G6</td>\n",
       "      <td>Notebook</td>\n",
       "      <td>15.6</td>\n",
       "      <td>Intel Core i5 7200U 2.5GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>Intel HD Graphics 620</td>\n",
       "      <td>No OS</td>\n",
       "      <td>1.86kg</td>\n",
       "      <td>575.00</td>\n",
       "      <td>Intel</td>\n",
       "      <td>256</td>\n",
       "      <td>SSD</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Apple</td>\n",
       "      <td>MacBook Pro</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>15.4</td>\n",
       "      <td>Intel Core i7 2.7GHz</td>\n",
       "      <td>16GB</td>\n",
       "      <td>AMD Radeon Pro 455</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.83kg</td>\n",
       "      <td>2537.45</td>\n",
       "      <td>Intel</td>\n",
       "      <td>512</td>\n",
       "      <td>SSD</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Apple</td>\n",
       "      <td>MacBook Pro</td>\n",
       "      <td>Ultrabook</td>\n",
       "      <td>13.3</td>\n",
       "      <td>Intel Core i5 3.1GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>Intel Iris Plus Graphics 650</td>\n",
       "      <td>macOS</td>\n",
       "      <td>1.37kg</td>\n",
       "      <td>1803.60</td>\n",
       "      <td>Intel</td>\n",
       "      <td>256</td>\n",
       "      <td>SSD</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Company      Product   TypeName  Inches                         Cpu   Ram  \\\n",
       "0   Apple  MacBook Pro  Ultrabook    13.3        Intel Core i5 2.3GHz   8GB   \n",
       "1   Apple  Macbook Air  Ultrabook    13.3        Intel Core i5 1.8GHz   8GB   \n",
       "2      HP       250 G6   Notebook    15.6  Intel Core i5 7200U 2.5GHz   8GB   \n",
       "3   Apple  MacBook Pro  Ultrabook    15.4        Intel Core i7 2.7GHz  16GB   \n",
       "4   Apple  MacBook Pro  Ultrabook    13.3        Intel Core i5 3.1GHz   8GB   \n",
       "\n",
       "                            Gpu  OpSys  Weight  Price_euros Cpu_Company  \\\n",
       "0  Intel Iris Plus Graphics 640  macOS  1.37kg      1339.69       Intel   \n",
       "1        Intel HD Graphics 6000  macOS  1.34kg       898.94       Intel   \n",
       "2         Intel HD Graphics 620  No OS  1.86kg       575.00       Intel   \n",
       "3            AMD Radeon Pro 455  macOS  1.83kg      2537.45       Intel   \n",
       "4  Intel Iris Plus Graphics 650  macOS  1.37kg      1803.60       Intel   \n",
       "\n",
       "   Memory_Amount   Memory_Type  SSD  laptop_id  \n",
       "0            128           SSD    1          0  \n",
       "1            128  FlashStorage    0          1  \n",
       "2            256           SSD    1          2  \n",
       "3            512           SSD    1          3  \n",
       "4            256           SSD    1          4  "
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[\"laptop_id\"] = df.index\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>client_id</th>\n",
       "      <th>laptop_id</th>\n",
       "      <th>Company</th>\n",
       "      <th>Product</th>\n",
       "      <th>TypeName</th>\n",
       "      <th>Inches</th>\n",
       "      <th>Cpu</th>\n",
       "      <th>Ram</th>\n",
       "      <th>Gpu</th>\n",
       "      <th>OpSys</th>\n",
       "      <th>Weight</th>\n",
       "      <th>Price_euros</th>\n",
       "      <th>Cpu_Company</th>\n",
       "      <th>Memory_Amount</th>\n",
       "      <th>Memory_Type</th>\n",
       "      <th>SSD</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>45</td>\n",
       "      <td>506</td>\n",
       "      <td>Asus</td>\n",
       "      <td>ZenBook UX510UX-CN211T</td>\n",
       "      <td>Notebook</td>\n",
       "      <td>15.6</td>\n",
       "      <td>Intel Core i7 7500U 2.7GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>Intel HD Graphics 620</td>\n",
       "      <td>Windows 10</td>\n",
       "      <td>2kg</td>\n",
       "      <td>1224.0</td>\n",
       "      <td>Intel</td>\n",
       "      <td>256</td>\n",
       "      <td>HDD</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>32</td>\n",
       "      <td>398</td>\n",
       "      <td>Dell</td>\n",
       "      <td>Precision M5520</td>\n",
       "      <td>Workstation</td>\n",
       "      <td>15.6</td>\n",
       "      <td>Intel Core i7 7700HQ 2.8GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>Nvidia Quadro M1200</td>\n",
       "      <td>Windows 10</td>\n",
       "      <td>1.78kg</td>\n",
       "      <td>2712.0</td>\n",
       "      <td>Intel</td>\n",
       "      <td>256</td>\n",
       "      <td>SSD</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>67</td>\n",
       "      <td>710</td>\n",
       "      <td>Lenovo</td>\n",
       "      <td>Legion Y520-15IKBN</td>\n",
       "      <td>Gaming</td>\n",
       "      <td>15.6</td>\n",
       "      <td>Intel Core i7 7700HQ 2.8GHz</td>\n",
       "      <td>8GB</td>\n",
       "      <td>Nvidia GeForce GTX 1050 Ti</td>\n",
       "      <td>Windows 10</td>\n",
       "      <td>2.5kg</td>\n",
       "      <td>1249.0</td>\n",
       "      <td>Intel</td>\n",
       "      <td>128</td>\n",
       "      <td>HDD</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>33</td>\n",
       "      <td>120</td>\n",
       "      <td>Acer</td>\n",
       "      <td>Spin 3</td>\n",
       "      <td>Notebook</td>\n",
       "      <td>15.6</td>\n",
       "      <td>Intel Core i3 7100U 2.4GHz</td>\n",
       "      <td>6GB</td>\n",
       "      <td>Intel HD Graphics 620</td>\n",
       "      <td>Windows 10</td>\n",
       "      <td>2.1kg</td>\n",
       "      <td>479.0</td>\n",
       "      <td>Intel</td>\n",
       "      <td>1024</td>\n",
       "      <td>HDD</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   client_id  laptop_id Company                 Product     TypeName  Inches  \\\n",
       "0         45        506    Asus  ZenBook UX510UX-CN211T     Notebook    15.6   \n",
       "1         32        398    Dell         Precision M5520  Workstation    15.6   \n",
       "2         67        710  Lenovo      Legion Y520-15IKBN       Gaming    15.6   \n",
       "3         33        120    Acer                  Spin 3     Notebook    15.6   \n",
       "\n",
       "                           Cpu  Ram                         Gpu       OpSys  \\\n",
       "0   Intel Core i7 7500U 2.7GHz  8GB       Intel HD Graphics 620  Windows 10   \n",
       "1  Intel Core i7 7700HQ 2.8GHz  8GB         Nvidia Quadro M1200  Windows 10   \n",
       "2  Intel Core i7 7700HQ 2.8GHz  8GB  Nvidia GeForce GTX 1050 Ti  Windows 10   \n",
       "3   Intel Core i3 7100U 2.4GHz  6GB       Intel HD Graphics 620  Windows 10   \n",
       "\n",
       "   Weight  Price_euros Cpu_Company  Memory_Amount Memory_Type  SSD  \n",
       "0     2kg       1224.0       Intel            256         HDD    0  \n",
       "1  1.78kg       2712.0       Intel            256         SSD    1  \n",
       "2   2.5kg       1249.0       Intel            128         HDD    0  \n",
       "3   2.1kg        479.0       Intel           1024         HDD    0  "
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "merged = clients.merge(df, on=\"laptop_id\")\n",
    "merged"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 4 задача\n",
    "\n",
    "Составьте несколько сводных таблиц"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 4.1 Найдите среднюю стоимость ноутбуков в зависимости от компании производителя\n",
    "\n",
    "Отсортируйте от меньшей стоимости к большей"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Price_euros</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Company</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Vero</th>\n",
       "      <td>217.425000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Mediacom</th>\n",
       "      <td>295.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Chuwi</th>\n",
       "      <td>314.296667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Acer</th>\n",
       "      <td>626.775825</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Fujitsu</th>\n",
       "      <td>729.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HP</th>\n",
       "      <td>1067.774854</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Lenovo</th>\n",
       "      <td>1086.384444</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Asus</th>\n",
       "      <td>1104.169367</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Xiaomi</th>\n",
       "      <td>1133.462500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Dell</th>\n",
       "      <td>1186.068990</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Toshiba</th>\n",
       "      <td>1267.812500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Samsung</th>\n",
       "      <td>1413.444444</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Huawei</th>\n",
       "      <td>1424.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Apple</th>\n",
       "      <td>1564.198571</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Microsoft</th>\n",
       "      <td>1612.308333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Google</th>\n",
       "      <td>1677.666667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>MSI</th>\n",
       "      <td>1728.908148</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>LG</th>\n",
       "      <td>2099.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Razer</th>\n",
       "      <td>3346.142857</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           Price_euros\n",
       "Company               \n",
       "Vero        217.425000\n",
       "Mediacom    295.000000\n",
       "Chuwi       314.296667\n",
       "Acer        626.775825\n",
       "Fujitsu     729.000000\n",
       "HP         1067.774854\n",
       "Lenovo     1086.384444\n",
       "Asus       1104.169367\n",
       "Xiaomi     1133.462500\n",
       "Dell       1186.068990\n",
       "Toshiba    1267.812500\n",
       "Samsung    1413.444444\n",
       "Huawei     1424.000000\n",
       "Apple      1564.198571\n",
       "Microsoft  1612.308333\n",
       "Google     1677.666667\n",
       "MSI        1728.908148\n",
       "LG         2099.000000\n",
       "Razer      3346.142857"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.groupby(\"Company\").agg({\"Price_euros\": \"mean\"}).sort_values(\"Price_euros\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 4.2 Найдите минимальную, среднюю и максимальную стоимости ноутбуков в зависимости от производителя процессора"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr:last-of-type th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th colspan=\"3\" halign=\"left\">Price_euros</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th>min</th>\n",
       "      <th>mean</th>\n",
       "      <th>max</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Cpu_Company</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>AMD</th>\n",
       "      <td>199.0</td>\n",
       "      <td>560.638871</td>\n",
       "      <td>2199.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Intel</th>\n",
       "      <td>174.0</td>\n",
       "      <td>1152.214145</td>\n",
       "      <td>6099.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Samsung</th>\n",
       "      <td>659.0</td>\n",
       "      <td>659.000000</td>\n",
       "      <td>659.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            Price_euros                     \n",
       "                    min         mean     max\n",
       "Cpu_Company                                 \n",
       "AMD               199.0   560.638871  2199.0\n",
       "Intel             174.0  1152.214145  6099.0\n",
       "Samsung           659.0   659.000000   659.0"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.groupby(\"Cpu_Company\").agg({\"Price_euros\": [\"min\", \"mean\", \"max\"]})"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 4.3 Постройте таблицу с подсчетом количества ноутбуков в данных в зависимости от производителя CPU и ОЗУ"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>Ram</th>\n",
       "      <th>12GB</th>\n",
       "      <th>16GB</th>\n",
       "      <th>24GB</th>\n",
       "      <th>2GB</th>\n",
       "      <th>32GB</th>\n",
       "      <th>4GB</th>\n",
       "      <th>64GB</th>\n",
       "      <th>6GB</th>\n",
       "      <th>8GB</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Cpu_Company</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>AMD</th>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>31</td>\n",
       "      <td>0</td>\n",
       "      <td>13</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Intel</th>\n",
       "      <td>23</td>\n",
       "      <td>197</td>\n",
       "      <td>3</td>\n",
       "      <td>21</td>\n",
       "      <td>17</td>\n",
       "      <td>343</td>\n",
       "      <td>1</td>\n",
       "      <td>28</td>\n",
       "      <td>607</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Samsung</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Ram          12GB  16GB  24GB  2GB  32GB  4GB  64GB  6GB  8GB\n",
       "Cpu_Company                                                  \n",
       "AMD             2     3     0    1     0   31     0   13   12\n",
       "Intel          23   197     3   21    17  343     1   28  607\n",
       "Samsung         0     0     0    0     0    1     0    0    0"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.pivot_table(\n",
    "    index=\"Cpu_Company\", columns=\"Ram\", values=\"Weight\", aggfunc=\"count\", fill_value=0\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 4.4 Постройте таблицу с подсчетом средней стоимости ноутбуков в данных в зависимости от операционной системы и GB памяти"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr:last-of-type th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th colspan=\"13\" halign=\"left\">Price_euros</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Memory_Amount</th>\n",
       "      <th>8</th>\n",
       "      <th>16</th>\n",
       "      <th>32</th>\n",
       "      <th>64</th>\n",
       "      <th>128</th>\n",
       "      <th>180</th>\n",
       "      <th>240</th>\n",
       "      <th>256</th>\n",
       "      <th>500</th>\n",
       "      <th>508</th>\n",
       "      <th>512</th>\n",
       "      <th>1024</th>\n",
       "      <th>2048</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>OpSys</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Android</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>434.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Chrome OS</th>\n",
       "      <td>0.0</td>\n",
       "      <td>305.38</td>\n",
       "      <td>412.454545</td>\n",
       "      <td>774.333333</td>\n",
       "      <td>1275.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1559.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2199.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Linux</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>742.250000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>811.638125</td>\n",
       "      <td>389.056364</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>581.401290</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Mac OS X</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1099.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1311.994000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1222.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>No OS</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>562.140000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>782.989286</td>\n",
       "      <td>404.675385</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1098.500000</td>\n",
       "      <td>540.539600</td>\n",
       "      <td>594.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Windows 10</th>\n",
       "      <td>2249.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>270.001471</td>\n",
       "      <td>499.716000</td>\n",
       "      <td>1026.489167</td>\n",
       "      <td>1073.5</td>\n",
       "      <td>3100.0</td>\n",
       "      <td>1334.456872</td>\n",
       "      <td>664.717647</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1911.985285</td>\n",
       "      <td>904.827906</td>\n",
       "      <td>666.9475</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Windows 10 S</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>308.995000</td>\n",
       "      <td>1039.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1668.950000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2589.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Windows 7</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1320.323333</td>\n",
       "      <td>1199.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1846.466800</td>\n",
       "      <td>924.048333</td>\n",
       "      <td>1002.0</td>\n",
       "      <td>2235.396667</td>\n",
       "      <td>1539.666667</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>macOS</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1119.315000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1600.370000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2180.870000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              Price_euros                                               \\\n",
       "Memory_Amount        8       16          32          64           128    \n",
       "OpSys                                                                    \n",
       "Android               0.0    0.00    0.000000  434.000000     0.000000   \n",
       "Chrome OS             0.0  305.38  412.454545  774.333333  1275.000000   \n",
       "Linux                 0.0    0.00    0.000000    0.000000   742.250000   \n",
       "Mac OS X              0.0    0.00    0.000000    0.000000  1099.000000   \n",
       "No OS                 0.0    0.00    0.000000    0.000000   562.140000   \n",
       "Windows 10         2249.0    0.00  270.001471  499.716000  1026.489167   \n",
       "Windows 10 S          0.0    0.00    0.000000  308.995000  1039.000000   \n",
       "Windows 7             0.0    0.00    0.000000    0.000000  1320.323333   \n",
       "macOS                 0.0    0.00    0.000000    0.000000  1119.315000   \n",
       "\n",
       "                                                                             \\\n",
       "Memory_Amount    180     240          256         500     508          512    \n",
       "OpSys                                                                         \n",
       "Android           0.0     0.0     0.000000    0.000000     0.0     0.000000   \n",
       "Chrome OS         0.0     0.0  1559.000000    0.000000     0.0  2199.000000   \n",
       "Linux             0.0     0.0   811.638125  389.056364     0.0     0.000000   \n",
       "Mac OS X          0.0     0.0  1311.994000    0.000000     0.0  1222.000000   \n",
       "No OS             0.0     0.0   782.989286  404.675385     0.0  1098.500000   \n",
       "Windows 10     1073.5  3100.0  1334.456872  664.717647     0.0  1911.985285   \n",
       "Windows 10 S      0.0     0.0  1668.950000    0.000000     0.0  2589.000000   \n",
       "Windows 7      1199.0     0.0  1846.466800  924.048333  1002.0  2235.396667   \n",
       "macOS             0.0     0.0  1600.370000    0.000000     0.0  2180.870000   \n",
       "\n",
       "                                      \n",
       "Memory_Amount         1024      2048  \n",
       "OpSys                                 \n",
       "Android           0.000000    0.0000  \n",
       "Chrome OS         0.000000    0.0000  \n",
       "Linux           581.401290    0.0000  \n",
       "Mac OS X          0.000000    0.0000  \n",
       "No OS           540.539600  594.0000  \n",
       "Windows 10      904.827906  666.9475  \n",
       "Windows 10 S      0.000000    0.0000  \n",
       "Windows 7      1539.666667    0.0000  \n",
       "macOS             0.000000    0.0000  "
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.groupby([\"OpSys\", \"Memory_Amount\"]).agg({\"Price_euros\": \"mean\"}).unstack(\n",
    "    \"Memory_Amount\"\n",
    ").fillna(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>Memory_Amount</th>\n",
       "      <th>8</th>\n",
       "      <th>16</th>\n",
       "      <th>32</th>\n",
       "      <th>64</th>\n",
       "      <th>128</th>\n",
       "      <th>180</th>\n",
       "      <th>240</th>\n",
       "      <th>256</th>\n",
       "      <th>500</th>\n",
       "      <th>508</th>\n",
       "      <th>512</th>\n",
       "      <th>1024</th>\n",
       "      <th>2048</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>OpSys</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Android</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>434.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Chrome OS</th>\n",
       "      <td>0.0</td>\n",
       "      <td>305.38</td>\n",
       "      <td>412.45</td>\n",
       "      <td>774.33</td>\n",
       "      <td>1275.00</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1559.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2199.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Linux</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>742.25</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>811.64</td>\n",
       "      <td>389.06</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>581.40</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Mac OS X</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>1099.00</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1311.99</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1222.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>No OS</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>562.14</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>782.99</td>\n",
       "      <td>404.68</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1098.50</td>\n",
       "      <td>540.54</td>\n",
       "      <td>594.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Windows 10</th>\n",
       "      <td>2249.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>270.00</td>\n",
       "      <td>499.72</td>\n",
       "      <td>1026.49</td>\n",
       "      <td>1073.5</td>\n",
       "      <td>3100.0</td>\n",
       "      <td>1334.46</td>\n",
       "      <td>664.72</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1911.99</td>\n",
       "      <td>904.83</td>\n",
       "      <td>666.95</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Windows 10 S</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>309.00</td>\n",
       "      <td>1039.00</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1668.95</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2589.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Windows 7</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>1320.32</td>\n",
       "      <td>1199.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1846.47</td>\n",
       "      <td>924.05</td>\n",
       "      <td>1002.0</td>\n",
       "      <td>2235.40</td>\n",
       "      <td>1539.67</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>macOS</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>1119.32</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1600.37</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2180.87</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Memory_Amount    8       16      32      64       128     180     240   \\\n",
       "OpSys                                                                    \n",
       "Android           0.0    0.00    0.00  434.00     0.00     0.0     0.0   \n",
       "Chrome OS         0.0  305.38  412.45  774.33  1275.00     0.0     0.0   \n",
       "Linux             0.0    0.00    0.00    0.00   742.25     0.0     0.0   \n",
       "Mac OS X          0.0    0.00    0.00    0.00  1099.00     0.0     0.0   \n",
       "No OS             0.0    0.00    0.00    0.00   562.14     0.0     0.0   \n",
       "Windows 10     2249.0    0.00  270.00  499.72  1026.49  1073.5  3100.0   \n",
       "Windows 10 S      0.0    0.00    0.00  309.00  1039.00     0.0     0.0   \n",
       "Windows 7         0.0    0.00    0.00    0.00  1320.32  1199.0     0.0   \n",
       "macOS             0.0    0.00    0.00    0.00  1119.32     0.0     0.0   \n",
       "\n",
       "Memory_Amount     256     500     508      512      1024    2048  \n",
       "OpSys                                                             \n",
       "Android           0.00    0.00     0.0     0.00     0.00    0.00  \n",
       "Chrome OS      1559.00    0.00     0.0  2199.00     0.00    0.00  \n",
       "Linux           811.64  389.06     0.0     0.00   581.40    0.00  \n",
       "Mac OS X       1311.99    0.00     0.0  1222.00     0.00    0.00  \n",
       "No OS           782.99  404.68     0.0  1098.50   540.54  594.00  \n",
       "Windows 10     1334.46  664.72     0.0  1911.99   904.83  666.95  \n",
       "Windows 10 S   1668.95    0.00     0.0  2589.00     0.00    0.00  \n",
       "Windows 7      1846.47  924.05  1002.0  2235.40  1539.67    0.00  \n",
       "macOS          1600.37    0.00     0.0  2180.87     0.00    0.00  "
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# second variant\n",
    "df.pivot_table(\n",
    "    index=\"OpSys\",\n",
    "    columns=\"Memory_Amount\",\n",
    "    aggfunc=\"mean\",\n",
    "    values=\"Price_euros\",\n",
    "    fill_value=0,\n",
    ").round(2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 5 задача\n",
    "\n",
    "Ответьте на несколько вопросов\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 5.1 Ноутбуков каких компаний и с каким процессором больше?\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>Cpu_Company</th>\n",
       "      <th>Company</th>\n",
       "      <th>AMD</th>\n",
       "      <th>Intel</th>\n",
       "      <th>Samsung</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Dell</td>\n",
       "      <td>0</td>\n",
       "      <td>297</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>Lenovo</td>\n",
       "      <td>16</td>\n",
       "      <td>281</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>HP</td>\n",
       "      <td>25</td>\n",
       "      <td>249</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Asus</td>\n",
       "      <td>11</td>\n",
       "      <td>147</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Acer</td>\n",
       "      <td>10</td>\n",
       "      <td>93</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>MSI</td>\n",
       "      <td>0</td>\n",
       "      <td>54</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>Toshiba</td>\n",
       "      <td>0</td>\n",
       "      <td>48</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Apple</td>\n",
       "      <td>0</td>\n",
       "      <td>21</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>Samsung</td>\n",
       "      <td>0</td>\n",
       "      <td>8</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>Mediacom</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>Razer</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>Microsoft</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>Vero</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>Xiaomi</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Chuwi</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Fujitsu</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>Google</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>LG</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Huawei</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Cpu_Company    Company  AMD  Intel  Samsung\n",
       "4                 Dell    0    297        0\n",
       "10              Lenovo   16    281        0\n",
       "7                   HP   25    249        0\n",
       "2                 Asus   11    147        0\n",
       "0                 Acer   10     93        0\n",
       "11                 MSI    0     54        0\n",
       "16             Toshiba    0     48        0\n",
       "1                Apple    0     21        0\n",
       "15             Samsung    0      8        1\n",
       "12            Mediacom    0      7        0\n",
       "14               Razer    0      7        0\n",
       "13           Microsoft    0      6        0\n",
       "17                Vero    0      4        0\n",
       "18              Xiaomi    0      4        0\n",
       "3                Chuwi    0      3        0\n",
       "5              Fujitsu    0      3        0\n",
       "6               Google    0      3        0\n",
       "9                   LG    0      3        0\n",
       "8               Huawei    0      2        0"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.crosstab(index=df[\"Company\"], columns=df[\"Cpu_Company\"]).reset_index().sort_values(\n",
    "    [\"Intel\", \"AMD\", \"Samsung\"], ascending=False\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 5.2 С каким типом памяти и с каким объемом памяти больше ноутбуков?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>Memory_Amount</th>\n",
       "      <th>8</th>\n",
       "      <th>16</th>\n",
       "      <th>32</th>\n",
       "      <th>64</th>\n",
       "      <th>128</th>\n",
       "      <th>180</th>\n",
       "      <th>240</th>\n",
       "      <th>256</th>\n",
       "      <th>500</th>\n",
       "      <th>508</th>\n",
       "      <th>512</th>\n",
       "      <th>1024</th>\n",
       "      <th>2048</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Memory_Type</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>FlashStorage</th>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "      <td>38</td>\n",
       "      <td>15</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>8</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>HDD</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>97</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>85</td>\n",
       "      <td>132</td>\n",
       "      <td>0</td>\n",
       "      <td>17</td>\n",
       "      <td>227</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Hybrid</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>9</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SSD</th>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>76</td>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "      <td>414</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>120</td>\n",
       "      <td>14</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Memory_Amount  8     16    32    64    128   180   240   256   500   508   \\\n",
       "Memory_Type                                                                 \n",
       "FlashStorage      0     7    38    15     4     0     0     8     0     0   \n",
       "HDD               0     0     1     1    97     0     0    85   132     0   \n",
       "Hybrid            0     0     0     0     0     0     0     1     0     1   \n",
       "SSD               1     3     6     1    76     5     1   414     0     0   \n",
       "\n",
       "Memory_Amount  512   1024  2048  \n",
       "Memory_Type                      \n",
       "FlashStorage      2     0     0  \n",
       "HDD              17   227    16  \n",
       "Hybrid            1     9     0  \n",
       "SSD             120    14     0  "
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = pd.crosstab(index=df[\"Memory_Type\"], columns=df[\"Memory_Amount\"])\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [],
   "source": [
    "a.to_excel(r\"1.xlsx\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
